package dao;

import java.util.List;

import model.MarcaProduto;
import model.ModeloVeiculos;

import org.hibernate.Criteria;
import org.hibernate.Session;

import org.hibernate.Transaction;

import util.HibernateUtil;

public class ModeloVeiculoDAO {
    public ModeloVeiculoDAO() {
        session = HibernateUtil.getSessionFactory().openSession();
    }
    
    private Session session;
    
    public void insert(ModeloVeiculos mv){
        Transaction t = session.beginTransaction();
        session.merge(mv);
        t.commit();
    }
    
    public void delete(ModeloVeiculos mv){
        Transaction t = session.beginTransaction();
        session.delete(mv);
        t.commit();
    }
    
    public List<ModeloVeiculos> findAll(){
        Criteria criteria = session.createCriteria(ModeloVeiculos.class);
        return criteria.list();
    }
    
    public static void main(String[] args) {
        ModeloVeiculoDAO mvDAO = new ModeloVeiculoDAO();
        for (ModeloVeiculos mv : mvDAO.findAll()){
            System.out.println(mv.getDescricao());
        }
    }
  
}
